﻿; 视频转图片
; 用法ffmpeg_Video_img("E:\test\Smoke.mov")
; 注意需要配置ffmpeg = ffmpeg.exe
;FFmpeg

ffmpeg_Video_img(path = "")
    {
		InputBox, UserInput, 隔帧输出, , , 200, 100, , , , ,1
		if ErrorLevel
			return
		else      
			command_extract = "select=(gte(n\,%UserInput%))*not(mod(n\,%UserInput%))"
			outfiles := "%05d.png"
			SplitPath, path, name, dir, ext, name_no_ext, drive
			CreateDir = %dir%\%name_no_ext%
			FileCreateDir,%CreateDir%
			FFmpeg=%A_ScriptDir%\tools\TotalCMD\Plugins\WLX\vlister\ffmpeg.exe
			run, %FFmpeg% -i "%path%" -vf %command_extract% -vsync 0 "%CreateDir%\%name_no_ext%_%outfiles%"
			Sleep,200
			run %CreateDir%
			return
    }
ffmpeg_Video_gif(path = "")
    {
	; 	InputBox, UserInput, 隔帧输出, , , 200, 100, , , , ,1
	; 	if ErrorLevel
	; 		return
	; 	else      
			command_extract = "-vcodec libwebp -lossless 1 -loop 0 -preset default -an -vsync 0"
			outfiles := ".gif"
			SplitPath, path, name, dir, ext, name_no_ext, drive
			CreateDir = %dir%
			FileCreateDir,%CreateDir%
			FFmpeg=%A_ScriptDir%\tools\TotalCMD\Plugins\WLX\vlister\ffmpeg.exe
			run, %FFmpeg% -i "%path%" -lossless 6 -q:v 100 -loop 0 -preset default -an -vsync 0 "%CreateDir%\%name_no_ext%%outfiles%"
			Sleep,200
			; run %CreateDir%
			return
    }

ffmpeg_Video_tsmp4(path = "")
    {
	; 	InputBox, UserInput, 隔帧输出, , , 200, 100, , , , ,1
	; 	if ErrorLevel
	; 		return
	; 	else      
			outfiles := ".mp4"
			SplitPath, path, name, dir, ext, name_no_ext, drive
			CreateDir = %dir%
			FileCreateDir,%CreateDir%
			FFmpeg=%A_ScriptDir%\tools\TotalCMD\Plugins\WLX\vlister\ffmpeg.exe
			MsgBox,  %FFmpeg% -y -i "%path%" -c:v libx264 -c:a copy -bsf:a aac_adtstoasc "%CreateDir%\%name_no_ext%%outfiles%"
			Sleep,200
			; run %CreateDir%
			return
    }
ffmpeg_Video_mp4ac(path = "")
    {
	; 	InputBox, UserInput, 隔帧输出, , , 200, 100, , , , ,1
	; 	if ErrorLevel
	; 		return
	; 	else      
			outfiles := ".aac"
			SplitPath, path, name, dir, ext, name_no_ext, drive
			CreateDir = %dir%
			FileCreateDir,%CreateDir%
			FFmpeg=%A_ScriptDir%\tools\TotalCMD\Plugins\WLX\vlister\ffmpeg.exe
			run,  %FFmpeg% -i "%path%" -vn -acodec copy "%CreateDir%\%name_no_ext%%outfiles%"
			Sleep,200
			; run %CreateDir%
			return
    }